package cn.wolfcode.wolf2w.service.impl;

import cn.wolfcode.wolf2w.domain.Spot;
import cn.wolfcode.wolf2w.repository.SpotRepository;
import cn.wolfcode.wolf2w.service.ISpotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.util.List;
/**
* 用户服务接口实现
*/
@Service
//@Transactional  现在写不能事务, 需要讲完复制集才能使用事务
public class SpotServiceImpl implements ISpotService {

    @Autowired
    private SpotRepository repsitory;

    @Autowired
    private MongoTemplate template;

    @Override
    public void save(Spot spot) {
        spot.setId(null);
        repsitory.save(spot);
    }

    @Override
    public void update(Spot spot) {
        repsitory.save(spot);
    }


    @Override
    public Spot get(String id) {
        return repsitory.findById(id).orElse(null);
    }

    @Override
    public List<Spot> list() {
        return repsitory.findAll();
    }
}
